/**
* @Description: WoShop商城
* @Author: 梧桐
* @Copyright: 武汉一一零七科技有限公司©版权所有
* @Link: www.wo-shop.net
* @Contact: QQ:2487937004
*/
<template>
  <view class="index_class">
    <view class="goods_info">
      <image class="goods_cover" :src="goodsInfo.thumb_url" />
      <view style="padding:0 40upx 0 20upx;flex:1">
        <view class="goods_introduce">{{goodsInfo.goods_name}}</view>
        <view class="arrt-str"></view>
      </view>
    </view>
    <view class="rele-areat">
      <!--  app 端状态栏站位 -->
      <view class="input-text">
        <textarea v-model="textValue" name="" id="" cols="30" rows="10" :placeholder="$t('写点想要说的话吧...')"></textarea>
        <view class="text-number">{{textValue.length}}/800</view>
      </view>
      
      <view class="addfile">
        <view class="grace-add-file">
          
            <u-upload
              width="160"
              height="160"
              max-count="6"
              :action="upLoadAction"
              :form-data="formData"
              :upload-text="$t('选择图片')"
              @on-success="uploadSuccess"
              ref="uUpload"
            ></u-upload>
          
        </view>
      </view>
      <view class="shoppin">
        <view class="feedback-star-view">
          <text>{{$t('商品评分')}}</text>
          <uni-rate class="unirate" value="0" @change="changeGoodsStar"></uni-rate>
        </view>
        <view class="feedback-star-view">
          <text>{{$t('物流评分')}}</text>
          <uni-rate class="unirate" value="0" @change="changeLogisticsStar"></uni-rate>
        </view>
        <view class="feedback-star-view">
          <text>{{$t('服务评分')}}</text>
          <uni-rate class="unirate" value="0" @change="changeServiceStar"></uni-rate>
        </view>
      </view>
      <view class="person-button" style="margin:0;background-color:#fff;padding-top:40upx">
        <button type="warn" class="btn" @click="getaddthorder">{{$t('发 布')}}</button>
      </view>
    </view>
  </view>
</template>


<script>
import uniRate from '../components/uni-rate/uni-rate'
var maxNum = 9,
    _self;
export default {
  data() {
    return {
      order_id: '',
      goodsId: '',
      goodsInfo: '',
      list: [1, 2, 3, 4, 5, 6],
      imgLists: [],
      btnImg: true,
	  pic: '',
      graceSelectTips: [{
        name: 'php',
        value: '0',
        checked: true
      },
        {
          name: '.net',
          value: '1',
          checked: false
        },
        {
          name: 'java',
          value: '2',
          checked: false
        },
        {
          name: 'nodeJs',
          value: '3',
          checked: false
        },
        {
          name: this.$t('其他'),
          value: '4',
          checked: false
        },
        {
          name: this.$t('其他'),
          value: '5',
          checked: false
        },
        {
          name: this.$t('其他'),
          value: '6',
          checked: false
        },
      ],
      textValue: '',
      goodsList: [],
      goddsName: [],
      pickValue: [],
      goodsStarValue: '0',
      logisticsStarValue: '0',
      serviceStarValue: '0',
	  formData: {},
	  upLoadAction: this.$baseUrl + "api/Common/uploadPic",
    }
  },
  components: {
    uniRate
  },
  onLoad(option) {
    _self = this;
    this.getOrderID(option);
    this.goodsId = option.goods_id;
    this.getGoodsInfo();
	
	this.formData = this.$http.returnCommonParams(
	  "api/Common/uploadPic",
	  "comment"
	);
  },
  
  
  methods: {
    
    getOrderID(option) {
      this.order_id = option.id;
    },
    changeGoodsStar(e) {
      this.goodsStarValue = e.value;
    },
    changeLogisticsStar(e) {
      this.logisticsStarValue = e.value;
    },
    changeServiceStar(e) {
      this.serviceStarValue = e.value;
    },
	uploadSuccess(res) {
		this.$toast(res.mess)
		if (res.status == 200) {
			this.pic = res.data.path
		}
	},
    getGoodsInfo(){
      this.$http.getGoodsInfo({ goods_id: this.goodsId }).then(res => {
        if (res.status == 200) {
          this.goodsInfo = res.data.goodsinfo;
          
        }
      });
    },
    /**
     *提交审核
     */
    async getaddthorder() {
      if (this.textValue == '') {
        this.$toast(this.$t('请输入评价内容'))
        return false
      }
      if (this.goodsStarValue == '0') {
        this.$toast(this.$t('请给商品打分'))
        return false
      }
      if (this.logisticsStarValue == '0') {
        this.$toast(this.$t('请给物流打分'))
        return false
      }
      if (this.serviceStarValue == '0') {
        this.$toast(this.$t('请给服务打分'))
        return false
      }
   
	let data = {
	  content: this.textValue,
	  goods_star: this.goodsStarValue,
	  logistics_star: this.logisticsStarValue,
	  service_star: this.serviceStarValue,
	  pic: this.pic,
	  order_id: this.order_id,
	  goods_id: this.goodsId,
	}
	
	this.$http.getaddgoodscomment(data).then(res => {
	  if (res.status == 200) {
		this.$toast(res.mess)
		setTimeout(() => {
		  this.isClick = true;
		  this.getback()
		}, 1500)
	  }
	});
        
    },
  }
}
</script>

<style>
.goods_info {
  display: flex;
  justify-content: flex-start;
  padding: 15upx 30upx;
  background: #FFFFFF;
  margin-bottom: 3upx;
  color: #717171;
}
.goods_cover {
  width: 108upx;
  height: 108upx;
  border-radius: 10upx;
  border: dotted 1px #eeeeee;
}
</style>
